<?php

namespace IDock\Insurance\HBIC\Request;

use IDock\Http\Request;
use IDock\Http\RequestFormat;
use IDock\Http\RequestMethod;
use IDock\Http\Response;

class AllHBICRequest extends Request {

    protected $code;

    protected $method = RequestMethod::POST;

    protected $format = RequestFormat::RAW;

    public $isNonCar = false;

    public function loadConfig(array $config): Request
    {

        $this->gateway = $config['gateway'] ?? '';

        $this->logsDir = $config['logsDir'] ?? '';

        $this->timeout = $config['timeout'] ?? '';

        $this->proxy = $config['proxy'] ?? '';

        $this->proxyPW = $config['proxyPW'] ?? '';

        $this->proxyAccount = $config['proxyAccount'] ?? '';

        return  $this;
    }

    /**
     * @return mixed
     */
    public function getCode()
    {
        return $this->code;
    }

    public function getStaffValue(&$comCode)
    {

    }

    public function responseLogs($uuid, $data)
    {
        $data = str_replace(["\r\n","\n","\r","\t"],['','','','',''],$data);
        $repLogs = date('Y-m-d H:i:s') . " RESPONSE " . $uuid . " " . $data;
        file_put_contents($this->logsFile, $repLogs . "\r\n", FILE_APPEND);
    }

}
